#include <stdio.h>
#include <syslog.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>

int main(int argc,char **argv)
{

	char          *progname=argv[0];

	if(daemon(0,0) < 0)
	{
		printf("create daemon failure:%s",strerror(errno));
		return -1;
	}

	openlog("hello",LOG_CONS | LOG_PID, 0);
	syslog(LOG_NOTICE, "Program '%s'start running\n", progname);
       	syslog(LOG_WARNING, "Program '%s' running with a warnning message\n", progname );
	syslog(LOG_EMERG, "Program '%s' running with a emergency message\n", progname );


	while(1)
	{}

	syslog(LOG_NOTICE, "Program '%s' stop running\n", progname);
	closelog();
	return 0;
}
